﻿using Study.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp4
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            listBox.Items.Add(new Person() { Id = 1, Name = "张三", Address = "江西省抚州市宜黄县" });
            listBox.Items.Add(new Person() { Id = 2, Name = "李四", Address = "广东省深圳市龙岗区" });
            listBox.Items.Add(new Person() { Id = 3, Name = "王五", Address = "北京市西二旗上地" });
        }

        private void txtDisplay_SelectionChanged(object sender, RoutedEventArgs e)
        {
            var selectedItem = listBox.SelectedItem as Person;
            txtDisplay.Text= selectedItem.Name.ToString();
        }
    }
}
